﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using corpus_platform.Data;
using corpus_platform.ViewModels;

namespace corpus_platform.Views
{
    /// <summary>
    /// AnnotationView.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.Container.ItemTemplateSelector = new StructureTemplateSelector();
        }

        private void TextBox_SelectionChanged(object sender, RoutedEventArgs e)
        {
            TextBox textBox = (TextBox)sender;
            if (textBox != null)
            {
                CustomDependencyProperty.SetSelectedText(textBox, textBox.SelectedText);
                CustomDependencyProperty.SetSelectedTextPosition(textBox, textBox.SelectionStart);
            }
            e.Handled = true;
        }

        protected override void OnDrop(DragEventArgs e)
        {
            base.OnDrop(e);
            try
            {
                INodeStructure structure = e.Data.GetData("Node") as INodeStructure;
                if (structure != null)
                {
                    structure.ChangeParentTo(structure.Root);
                }
            }
            finally
            {
                e.Handled = true;
            }
        }

    }
}
